Skip to content

Conversation

@hop-dev
Copy link
Collaborator

@hop-dev hop-dev commented Mar 3, 2025

Add --space parameter to the entity-store and entity-resolution-demo commands.

Some of our URLs had a URL constant which took a space a parameter, some didn't. As every Kibana URL supports spaces I thought it better to have kibanaFetch handle spaces.

@hop-dev hop-dev requested a review from Copilot March 3, 2025 11:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors space handling by moving URL space logic into kibanaFetch and adds support for a --space parameter in multiple commands. Key changes include:

  • Adding a --space option to the entity-resolution-demo and entity-store commands.
  • Refactoring kibanaFetch and related URL generators to accept a space parameter and use new API version constants.
  • Updating asset criticality and rule creation functions to propagate the space parameter.

Reviewed Changes

File Description
src/index.ts Adds the --space option to entity-resolution-demo and entity-store commands
src/utils/kibana_api.ts Refactors URL building with buildKibanaUrl and improves API version handling
src/constants.ts Introduces API_VERSIONS and updates URL generators for rules and packages
src/utils/initialize_space.ts Renames getSpace to doesSpaceExist for clarity in space checks
src/commands/entity-store.ts Propagates the space parameter, including initializing space if non-default
src/commands/entity_resolution.ts Updates package installation and rule creation to include the space parameter
src/commands/asset_criticality.ts Includes the space parameter when generating asset criticality
src/commands/documents.ts Removes outdated commented code

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

src/commands/entity_resolution.ts:482

  • There is a typo in the comment: 'inttegrations' should be 'integrations'.
    // which the inttegrations don't provide

src/utils/kibana_api.ts:188

  • [nitpick] For consistency with other URL constructions using buildKibanaUrl, consider refactoring getRule (and similarly deleteRule) to build the URL using buildKibanaUrl with query parameter handling rather than concatenating strings directly.
const url = DETECTION_ENGINE_RULES_URL + '?rule_id=' + ruleId;

Copy link
Contributor

@CAWilson94 CAWilson94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@hop-dev hop-dev merged commit 0310393 into elastic:main Mar 3, 2025
2 checks passed
@hop-dev hop-dev deleted the add-space-to-all-commands branch March 3, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants